home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0068_FILEIO2.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1994-02-03  |  30KB  |  530 lines

  1. {
  2. From: GREG ESTABROOKS
  3. Subj: FileIO.Pas
  4. ---------------------------------------------------------------------------
  5. }
  6.  
  7. UNIT FILEIO;            { Low Level File handling routines. Jan 18/94   }
  8.                         { Copyright (C) 1993,1994 Greg Estabrooks       }
  9.                         { NOTE: Requires TP 6.0+ to compile.            }
  10. INTERFACE
  11. {***********************************************************************}
  12. USES DOS;                       { IMPORT FSearch.                       }
  13. CONST                           { Handles PreDefined by DOS.            }
  14.      fStdIn     = $00;          { STD Input Device, (Keyboard).         }
  15.      fStdOut    = $01;          { STD Output Device,(CRT).              }
  16.      fStdErr    = $02;          { STD Error Device, (CRT).              }
  17.      fStdCom    = $03;          { STD Comm.                             }
  18.      fStdPrn    = $04;          { STD Printer.                          }
  19.      oRead      = $00;          { Opens a file for read only.           }
  20.      oWrite     = $01;          { Opens a file for writing only.        }
  21.      oReadWrite = $02;          { Opens a file for reading and writing. }
  22.      oDenyAll   = $10;          { Deny access to other processes.       }
  23.      oDenyWrite = $20;          { Deny write access to other processes. }
  24.      oDenyRead  = $30;          { Deny read access to other processes.  }
  25.      oDenyNone  = $40;          { Allow free access to other processes. }
  26.                                 { Possible file attribs,can be combined.}
  27.      aNormal   = $00;  aSystem = $04;  aArchive = $20;
  28.      aReadOnly = $01;  aVolume = $08;
  29.      aHidden   = $02;  aDir    = $10;
  30. TYPE
  31.     LockType = (Lock,UnLock);   { Ordinal Type for use with 'fLock'.    }
  32. VAR
  33.    fError  :WORD;               { Holds any error codes from routines.  }
  34.  
  35. PROCEDURE ASCIIZ( VAR fName :STRING );
  36.                          { Routine to add a NULL to a string to make it }
  37.                          { ASCIIZ compatible.                           }
  38.                          { File routines automatically call this routine}
  39.                          { usage :                                      }
  40.                          {  ASCIIZ(fName);                              }
  41.  
  42. FUNCTION  fCreate( fName :STRING; Attr :BYTE ) :WORD;
  43.                          { Routine to Create 'fName' with an attribute  }
  44.                          { of 'Attr'. If the file already exists then it}
  45.                          { will be truncated to a zero length file.     }
  46.                          { Returns a WORD value containing the  handle. }
  47.                          { Uses Int 21h/AH=3Ch.                         }
  48.                          { usage :                                      }
  49.                          {  handle := fCreate('Temp.Dat',aNormal);      }
  50.  
  51. FUNCTION  fOpen( fName :STRING; Mode :BYTE ) :WORD;
  52.                          { Routine to open already existing file defined}
  53.                          { in 'fName' with an opening mode of 'Mode'.   }
  54.                          { Returns a WORD value containing the  handle. }
  55.                          { Uses Int 21h/AH=3Dh.                         }
  56.                          { usage :                                      }
  57.                          {  handle := fOpen('Temp.Dat',oRead);          }
  58.  
  59. PROCEDURE fRead( fHandle :WORD; VAR Buff; NTRead:WORD; VAR ARead :WORD );
  60.                          { Reads 'NTRead' bytes of data from 'fHandle'  }
  61.                          { and puts it in 'Buff'. The actually amount   }
  62.                          { of bytes read is returned in 'ARead'.        }
  63.                          { Uses Int 21h/AH=3Fh.                         }
  64.                          { usage :                                      }
  65.                          {  fRead(handle,Buffer,SizeOf(Buffer),ARead);  }
  66.  
  67. PROCEDURE fWrite( fHandle :WORD; VAR Buff; NTWrite:WORD; VAR AWrite :WORD );
  68.                          { Writes 'NTWrite' bytes of info from 'Buff'   }
  69.                          { to 'fHandle'. The actually amount written is }
  70.                          { returned in 'AWrite'.                        }
  71.                          { Uses Int 21h/AH=40h.                         }
  72.                          { usage :                                      }
  73.                          {  fWrite(handle,Buffer,SizeOf(Buffer),AWrite);}
  74.  
  75. PROCEDURE fClose( fHandle :WORD );
  76.                          { Routine to close file 'fHandle'. This updates}
  77.                          { the directory time and size enteries.        }
  78.                          { Uses Int 21h/AH=3Eh.                         }
  79.                          { usage :                                      }
  80.                          {  fClose(handle);                             }
  81.  
  82. PROCEDURE fReset(  fHandle :WORD );
  83.                          { Routine to reset file position pointer to the}
  84.                          { beginning of 'fHandle'.                      }
  85.                          { Uses Int 21h/AH=42h.                         }
  86.                          { usage :                                      }
  87.                          {  fReset(handle);                             }
  88.  
  89. PROCEDURE fAppend( fHandle :WORD );
  90.                          { Routine to move the File position pointer of }
  91.                          { 'fHandle' to the end of the file. Any further}
  92.                          { writing is added to the end of the file.     }
  93.                          { Uses Int 21h/AH=42h.                         }
  94.                          { usage :                                      }
  95.                          {  fAppend(handle);                            }
  96.  
  97. PROCEDURE fSeek( fHandle :WORD; fOfs :LONGINT );
  98.                          { Routine to move the file position pointer for}
  99.                          { 'fHandle' to 'fOfs'. 'fOfs' is the actual    }
  100.                          { byte position in the file to move to.        }
  101.                          { Uses Int 21h/AH=42h.                         }
  102.                          { usage :                                      }
  103.                          {  fSeek(handle,1023);                         }
  104.  
  105. PROCEDURE fErase( fName :STRING );
  106.                          { Routine to erase 'fName'.                    }
  107.                          { Uses Int 21h/AH=41h.                         }
  108.                          { usage :                                      }
  109.                          {  fErase('Temp.Dat');                         }
  110.  
  111. FUNCTION  fPos( fHandle :WORD ) :LONGINT;
  112.                          { Routine to return the current position within}
  113.                          { 'fHandle'.                                   }
  114.                          { Uses Int 21h/AH=42.                          }
  115.                          { usage :                                      }
  116.                          {  CurPos := fPos(handle);                     }
  117.  
  118. FUNCTION  fEof( fHandle :WORD ) :BOOLEAN;
  119.                          { Routine to determine whether or not we're    }
  120.                          { currently at the end of file 'fHandle'.      }
  121.                          { usage :                                      }
  122.                          {  IsEnd := fEof(handle);                      }
  123.  
  124. FUNCTION  fExist( fName :STRING ) :BOOLEAN;
  125.                          { Routine to determine whether or not 'fName'  }
  126.                          { exists.                                      }
  127.                          { usage :                                      }
  128.                          {  Exist := fExist('Temp.Dat');                }
  129.  
  130. FUNCTION  fGetAttr( fName :STRING ) :BYTE;
  131.                          { Routine to return the current file attribute }
  132.                          { of 'fName'.                                  }
  133.                          { Uses Int 21h/AH=43h,AL=00h.                  }
  134.                          { usage :                                      }
  135.                          {  CurAttr := fGetAttr('Temp.Dat');            }
  136.  
  137. PROCEDURE fSetAttr( fName :STRING; NAttr :BYTE );
  138.                          { Routine to set file attribute of 'fName' to  }
  139.                          { 'NAttr'.                                     }
  140.                          { Uses Int 21h/AH=43h,AL=01h.                  }
  141.                          { usage :                                      }
  142.                          {  fSetAttr('Temp.Dat',aArchive OR aReadOnly); }
  143.  
  144. PROCEDURE fSetVerify( On_Off :BOOLEAN );
  145.                          { Routine to set the DOS verify flag ON or OFF.}
  146.                          { depending on 'On_Off'.                       }
  147.                          { TRUE = ON, FALSE = OFF.                      }
  148.                          { Uses Int 21h/AH=2Eh.                         }
  149.                          { usage :                                      }
  150.                          {  fSetVerify( TRUE );                         }
  151.  
  152. FUNCTION  fGetVerify :BOOLEAN;
  153.                          { Routine to return the current state of the   }
  154.                          { DOS verify flag.                             }
  155.                          { Uses Int 21h/AH=54h.                         }
  156.                          { usage :                                      }
  157.                          {  IsVerify := fGetVerify;                     }
  158.  
  159. FUNCTION  fSize( fHandle :WORD ) :LONGINT;
  160.                          { Routine to determine the size in bytes of    }
  161.                          { 'fHandle'.                                   }
  162.                          { usage :                                      }
  163.                          {  CurSize := fSize(handle);                   }
  164.  
  165. PROCEDURE fFlush( fHandle :WORD );
  166.                          { Flushes any File buffers for 'fHandle'       }
  167.                          { immediately and updates the directory entry. }
  168.                          { Uses Int 21h/AH=68h.                         }
  169.                          { usage :                                      }
  170.                          {  fFlush(handle);                             }
  171.  
  172. PROCEDURE fLock( fHandle :WORD; LockInf :LockType; StartOfs,Len :LONGINT );
  173.                          { Routine to lock/unlock parts of a open file.  }
  174.                          { Locking or unlock is determined by 'LockInf'. }
  175.                          { Uses Int 21h/AH=5Ch.                          }
  176.                          { usage :                                       }
  177.                          {  fLock(handle,Lock,1000,500);                 }
  178. {***********************************************************************}
  179. IMPLEMENTATION
  180.  
  181. PROCEDURE ASCIIZ( VAR fName :STRING ); ASSEMBLER;
  182.                          { Routine to add a NULL to a string to make it }
  183.                          { ASCIIZ compatible.                           }
  184.                          { File routines automatically call this routine}
  185. ASM
  186.   Push DS                       { Push DS onto the stack.               }
  187.   LDS DI,fname                  { Point DS:DI ---> fName.               }
  188.   Xor BX,BX                     { Clear BX.                             }
  189.   Mov BL,BYTE PTR DS:[DI]       { Load length of string into BL.        }
  190.   Inc BL                        { Point to char after last one in name. }
  191.   Mov BYTE PTR DS:[DI+BX],0     { Now make it a ASCIIZ string.          }
  192.   Pop DS                        { Pop DS off the stack.                 }
  193. END;{ASCIIZ}
  194.  
  195. FUNCTION  fCreate( fName :STRING; Attr :BYTE ) :WORD;
  196.                          { Routine to Create 'fName' with an attribute  }
  197.                          { of 'Attr'. If the file already exists then it}
  198.                          { will be truncated to a zero length file.     }
  199.                          { Returns a WORD value containing the  handle. }
  200.                          { Uses Int 21h/AH=3Ch.                         }
  201. BEGIN
  202.   ASCIIZ(fName);                { Convert fName to an ASCIIZ string.    }
  203.   ASM
  204.     Push DS                     { Push DS Onto stack.                   }
  205.     Mov fError,0                { Clear Error Flag.                     }
  206.     Mov AX,SS                   { Load AX with SS.                      }
  207.     Mov DS,AX                   { Now load that value into DS.          }
  208.     Lea DX,fName                { Now load DX with the offset of DX.    }
  209.     Inc DX                      { Move past length byte.                }
  210.     Xor CH,CH                   { Clear High byte of CX.                }
  211.     Mov CL,Attr                 { Load attribute to give new file.      }
  212.     Mov AH,$3C                  { Function to create a file.            }
  213.     Int $21                     { Call dos to create file.              }
  214.     Jnc @Exit                   { If no error exit.                     }
  215.     Mov fError,AX               { If there was an  error save it.       }
  216.   @Exit:
  217.     Mov @Result,AX              { Return proper result to user.         }
  218.     Pop DS                      { Pop DS Off the Stack.                 }
  219.   END;
  220. END;{fCreate}
  221.  
  222. FUNCTION  fOpen( fName :STRING; Mode :BYTE ) :WORD;
  223.                          { Routine to open already existing file defined}
  224.                          { in 'fName' with an opening mode of 'Mode'.   }
  225.                          { Returns a WORD value containing the  handle. }
  226.                          { Uses Int 21h/AH=3Dh.                         }
  227. BEGIN
  228.   ASCIIZ(fName);                { Convert fName to an ASCIIZ string.    }
  229.   ASM
  230.     Push DS                     { Push DS onto stack.                   }
  231.     Mov fError,0                { Clear Error Flag.                     }
  232.     Mov AX,SS                   { Load AX with SS.                      }
  233.     Mov DS,AX                   { Now load that value into DS.          }
  234.     Lea DX,fName                { Now load DX with the offset of DX.    }
  235.     Inc DX                      { Move past length byte.                }
  236.     Mov AH,$3D                  { Function to open a file.              }
  237.     Mov AL,Mode                 { File Opening mode.                    }
  238.     Int $21                     { Call dos to open file.                }
  239.     Jnc @Exit                   { If no error exit.                     }
  240.     Mov fError,AX               { If there was an  error save it.       }
  241.   @Exit:
  242.     Mov @Result,AX              { Return proper result to user.         }
  243.     Pop DS                      { Restore DS from stack.                }
  244.   END;
  245. END;{fOpen}
  246.  
  247. PROCEDURE fRead( fHandle :WORD; VAR Buff; NTRead:WORD; VAR ARead :WORD );
  248. ASSEMBLER;               { Reads 'NTRead' bytes of data from 'fHandle'  }
  249.                          { and puts it in 'Buff'. The actually amount   }
  250.                          { of bytes read is returned in 'ARead'.        }
  251.                          { Uses Int 21h/AH=3Fh.                         }
  252. ASM
  253.   Push DS                       { Push DS onto the stack.               }
  254.   Mov fError,0                  { Clear Error flag.                     }
  255.   Mov AH,$3F                    { Function to read from a file.         }
  256.   Mov BX,fHandle                { load handle of file to read.          }
  257.   Mov CX,NTRead                 { # of bytes to read.                   }
  258.   LDS DX,Buff                   { Point DS:DX to buffer.                }
  259.   Int $21                       { Call Dos to read file.                }
  260.   LDS DI,ARead                  { Point to amount read.                 }
  261.   Mov WORD PTR DS:[DI],AX       { Save amount actually read.            }
  262.   Jnc @Exit                     { if there was no error exit.           }
  263.   Mov fError,AX                 { If there was Save error code.         }
  264. @Exit:
  265.   Pop DS                        { Pop DS off the stack.                 }
  266. END;{fRead}
  267.  
  268. PROCEDURE fWrite( fHandle :WORD; VAR Buff; NTWrite:WORD; VAR AWrite :WORD );
  269. ASSEMBLER;               { Writes 'NTWrite' bytes of info from 'Buff'   }
  270.                          { to 'fHandle'. The actually amount written is }
  271.                          { returned in 'AWrite'.                        }
  272.                          { Uses Int 21h/AH=40h.                         }
  273. ASM
  274.   Push DS                       { Push DS onto the stack.               }
  275.   Mov fError,0                  { Clear Error flag.                     }
  276.   Mov AH,$40                    { Function to write to file.            }
  277.   Mov BX,fHandle                { Handle of file to write to.           }
  278.   Mov CX,NTWrite                { # of bytes to read.                   }
  279.   LDS DX,Buff                   { Point DS:DX -> Buffer.                }
  280.   Int $21                       { Call Dos to write to file.            }
  281.   LDS DI,AWrite                 { Point to amount write.                }
  282.   Mov WORD PTR DS:[DI],AX       { Save amount actually written.         }
  283.   Jnc @Exit                     { If there was no error exit.           }
  284.   Mov fError,AX                 { if there was save error code.         }
  285. @Exit:
  286.   Pop DS                        { Pop DS off the stack.                 }
  287. END;{fWrite}
  288.  
  289. PROCEDURE fClose( fHandle :WORD ); ASSEMBLER;
  290.                          { Routine to close file 'fHandle'. This updates}
  291.                          { the directory time and size enteries.        }
  292.                          { Uses Int 21h/AH=3Eh.                         }
  293. ASM
  294.   Mov fError,0                  { Clear Error flag                      }
  295.   Mov AH,$3E                    { Function to close file                }
  296.   Mov BX,fHandle                { load handle of file to close          }
  297.   Int $21                       { call Dos to close file                }
  298.   Jnc @Exit                     { If there was no error exit            }
  299.   Mov fError,AX                 { if there was save error code          }
  300. @Exit:
  301. END;{fClose}
  302.  
  303. PROCEDURE fReset( fHandle :WORD ); ASSEMBLER;
  304.                          { Routine to reset file position pointer to the}
  305.                          { beginning of 'fHandle'.                      }
  306.                          { Uses Int 21h/AH=42h.                         }
  307. ASM
  308.   Mov fError,0                  { Clear error flag.                     }
  309.   Mov AH,$42                    { Function to move file pointer.        }
  310.   Mov BX,fHandle                { Handle of file.                       }
  311.   Mov AL,0                      { Offset relative to begining.          }
  312.   Mov CX,0                      { CX:DX = offset from begining of file  }
  313.   Mov DX,0                      { to move to.                           }
  314.   Int $21                       { Call dos to change file pointer.      }
  315.   Jnc @Exit                     { If there was no error exit.           }
  316.   Mov fError,AX                 { If there was save error code.         }
  317. @Exit:
  318. END;{fReset}
  319.  
  320. PROCEDURE fAppend( fHandle :WORD); ASSEMBLER;
  321.                          { Routine to move the File position pointer of }
  322.                          { 'fHandle' to the end of the file. Any further}
  323.                          { writing is added to the end of the file.     }
  324.                          { Uses Int 21h/AH=42h.                         }
  325. ASM
  326.   Mov fError,0                  { Clear error flag.                     }
  327.   Mov AH,$42                    { Function to change file ptr position. }
  328.   Mov BX,fHandle                { handle of file to change.             }
  329.   Mov AL,$02                    { Change relative to end of file.       }
  330.   Mov CX,0                      { CX:DX = offset from end of file       }
  331.   Mov DX,0                      { to move to.                           }
  332.   Int $21                       { Call dos to move file ptr.            }
  333.   Jnc @Exit                     { If there was no error exit.           }
  334.   Mov fError,AX                 { If there was save error code.         }
  335. @Exit:
  336. END;{fAppend}
  337.  
  338. PROCEDURE fSeek( fHandle :WORD; fOfs :LONGINT ); ASSEMBLER;
  339.                          { Routine to move the file position pointer for}
  340.                          { 'fHandle' to 'fOfs'. 'fOfs' is the actual    }
  341.                          { byte position in the file to move to.        }
  342.                          { Uses Int 21h/AH=42h.                         }
  343. ASM
  344.   Mov fError,0                  { Clear error flag.                     }
  345.   Mov AH,$42                    { Function to change file ptr position. }
  346.   Mov BX,fHandle                { handle of file to change.             }
  347.   Mov AL,$00                    { Change relative to start of file.     }
  348.   Mov CX,fOfs[2].WORD           { CX:DX = offset from start of file     }
  349.   Mov DX,fOfs.WORD              { to move to.                           }
  350.   Int $21                       { Call dos to move file ptr.            }
  351.   Jnc @Exit                     { If there was no error exit.           }
  352.   Mov fError,AX                 { If there was save error code.         }
  353. @Exit:
  354. END;{fSeek}
  355.  
  356. PROCEDURE fErase( fName :STRING );
  357.                          { Routine to erase 'fName'.                    }
  358.                          { Uses Int 21h/AH=41h.                         }
  359. BEGIN
  360.   ASCIIZ(fName);                { Convert fName to an ASCIIZ string.    }
  361.   ASM
  362.     Push DS                     { Push DS onto the stack.               }
  363.     Mov fError,0                { Clear error flag.                     }
  364.     Mov AH,$41                  { Function to erase a file.             }
  365.     Mov AX,SS                   { Load AX with SS.                      }
  366.     Mov DS,AX                   { Now load that value into DS.          }
  367.     Lea DX,fName                { Now load DX with the offset of DX.    }
  368.     Inc DX
  369.     Int $21                     { Call dos to erase file.               }
  370.     Jnc @Exit                   { If no error exit.                     }
  371.     Mov fError,AX               { if there was error save error code.   }
  372.   @Exit:
  373.     Pop DS                      { Pop DS off the stack.                 }
  374.   END;
  375. END;{fErase}
  376.  
  377. FUNCTION  fPos( fHandle :WORD ) :LONGINT; ASSEMBLER;
  378.                          { Routine to return the current position within}
  379.                          { 'fHandle'.                                   }
  380.                          { Uses Int 21h/AH=42.                          }
  381. ASM
  382.   Mov fError,0                  { Clear error flag.                     }
  383.   Mov AH,$42                    { Function to move file pointer.        }
  384.   Mov BX,fHandle                { Handle of file.                       }
  385.   Mov AL,1                      { Offset relative to current pos.       }
  386.   Mov CX,0                      { CX:DX = offset from current position  }
  387.   Mov DX,0                      { to move to.                           }
  388.   Int $21                       { Call dos to change file pointer.      }
  389.   Jnc @Exit                     { If there was no error return result.  }
  390.   Mov fError,AX                 { If there was save error code.         }
  391. @Exit:                          { Int already returns DX:AX as file pos.}
  392. END;{fPos}
  393.  
  394. FUNCTION  fEof( fHandle :WORD ) :BOOLEAN;
  395.                          { Routine to determine whether or not we're    }
  396.                          { currently at the end of file 'fHandle'.      }
  397. VAR
  398.    CurOfs :LONGINT;             { current file offset.                  }
  399. BEGIN
  400.   CurOfs := fPos(fHandle);      { Save Current Pos.                     }
  401.   fAppend(fHandle);             { Move to the end of the file.          }
  402.   fEof := (CurOfs = fPos(fHandle)); { was current pos = end pos?.       }
  403.   fSeek(fHandle,CurOfs);        { Restore to original file position.    }
  404. END;{fEof}
  405.  
  406. FUNCTION  fExist( fName :STRING ) :BOOLEAN;
  407.                          { Routine to determine whether or not 'fName'  }
  408.                          { exists.                                      }
  409. BEGIN
  410.   fExist := ( FSearch(fName,'') <> '');
  411. END;{fExist}
  412.  
  413. FUNCTION  fGetAttr( fName :STRING ) :BYTE;
  414.                          { Routine to return the current file attribute }
  415.                          { of 'fName'.                                  }
  416.                          { Uses Int 21h/AH=43h,AL=00h.                  }
  417. BEGIN
  418.   ASCIIZ(fName);                { Convert fName to an ASCIIZ string.    }
  419.   ASM
  420.     Push DS                     { Push DS onto the stack.               }
  421.     Mov fError,0                { Clear error flag.                     }
  422.     Mov AX,SS                   { Load AX with SS.                      }
  423.     Mov DS,AX                   { Now load that value into DS.          }
  424.     Lea DX,fName                { Now load DX with the offset of DX.    }
  425.     Inc DX
  426.     Mov AX,$4300                { Function to Get file Attrib.          }
  427.     Int $21                     { Call dos to get attr.                 }
  428.     Jnc @Success                { If no error return proper info.       }
  429.     Mov fError,AX               { if there was error save error code.   }
  430.   @Success:
  431.     Mov AX,CX
  432.     Mov @Result,AL              { Return proper result to user.         }
  433.     Pop DS                      { Pop DS off the stack.                 }
  434.   END;
  435. END;{fGetAttr}
  436.  
  437. PROCEDURE fSetAttr( fName :STRING; NAttr :BYTE );
  438.                          { Routine to set file attribute of 'fName' to  }
  439.                          { 'NAttr'.                                     }
  440.                          { Uses Int 21h/AH=43h,AL=01h.                  }
  441. BEGIN
  442.   ASCIIZ(fName);                { Convert fName to an ASCIIZ string.    }
  443.   ASM
  444.     Push DS                     { Push DS onto the stack.               }
  445.     Mov fError,0                { Clear error flag.                     }
  446.     Mov AX,SS                   { Load AX with SS.                      }
  447.     Mov DS,AX                   { Now load that value into DS.          }
  448.     Lea DX,fName                { Now load DX with the offset of DX.    }
  449.     Inc DX                      { Point to first char after length byte.}
  450.     Xor CX,CX                   { Clear CX.                             }
  451.     Mov CL,NAttr                { Load New attribute byte.              }
  452.     Mov AX,$4301                { Function to Set file Attrib.          }
  453.     Int $21                     { Call dos to set attrib.               }
  454.     Jnc @Exit                   { If no error exit.                     }
  455.     Mov fError,AX               { if there was error save error code.   }
  456.   @Exit:
  457.     Pop DS                      { Pop DS off the stack.                 }
  458.   END;
  459. END;{fSetAttr}
  460.  
  461. PROCEDURE fSetVerify( On_Off :BOOLEAN ); ASSEMBLER;
  462.                          { Routine to set the DOS verify flag ON or OFF.}
  463.                          { depending on 'On_Off'.                       }
  464.                          { TRUE = ON, FALSE = OFF.                      }
  465.                          { Uses Int 21h/AH=2Eh.                         }
  466. ASM
  467.   Mov AH,$2E                    {  Interrupt Subfunction.               }
  468.   Mov DL,0                      {  Clear DL.                            }
  469.   Mov AL,On_Off                 {  0(FALSE) = off, 1(TRUE) = on.        }
  470.   Int $21                       {  Call Dos.                            }
  471. END;{fSetVerify}
  472.  
  473. FUNCTION  fGetVerify :BOOLEAN; ASSEMBLER;
  474.                          { Routine to return the current state of the   }
  475.                          { DOS verify flag.                             }
  476.                          { Uses Int 21h/AH=54h.                         }
  477. ASM
  478.   Mov AH,$54                    {  Interrupt Subfunction                }
  479.   Int $21                       {  Call Dos                             }
  480. END;{fGetVerify}
  481.  
  482. FUNCTION  fSize( fHandle :WORD ) :LONGINT;
  483.                          { Routine to determine the size in bytes of    }
  484.                          { 'fHandle'.                                   }
  485. VAR
  486.    CurOfs :LONGINT;             { Holds original file pointer.          }
  487. BEGIN
  488.   CurOfs := fPos(fHandle);      { Save current file pointer.            }
  489.   fAppend(fHandle);             { Move to end of file.                  }
  490.   fSize := fPos(fHandle);       { Save current pos which equals size.   }
  491.   fSeek(fHandle,CurOfs);        { Restore original file pos.            }
  492. END;{fSize}
  493.  
  494. PROCEDURE fFlush( fHandle :WORD ); ASSEMBLER;
  495.                          { Flushes any File buffers for 'fHandle'       }
  496.                          { immediately and updates the directory entry. }
  497.                          { Uses Int 21h/AH=68h.                         }
  498. ASM
  499.   Mov fError,0                  { Clear error flag.                     }
  500.   Mov AH,$68                    { Function to Commit file to disk.      }
  501.   Mov BX,fHandle                { Load handle of file to Commit.        }
  502.   Int $21                       { Call dos to flush file.               }
  503.   Jnc @Exit                     { If no error exit.                     }
  504.   Mov fError,AX                 { if there was error save error code.   }
  505. @Exit:
  506. END;{fSetAttr}
  507.  
  508. PROCEDURE fLock( fHandle :WORD; LockInf :LockType; StartOfs,Len :LONGINT );
  509.                          { Routine to lock/unlock parts of a open file.  }
  510. ASSEMBLER;               { Locking or unlock is determined by 'LockInf'. }
  511.                          { Uses Int 21h/AH=5Ch.                          }
  512.  
  513. ASM
  514.   Mov fError,0                  { Clear Error Flag.                     }
  515.   Mov AH,$5C                    { Function to lock/unlock part of a file.}
  516.   Mov AL,LockInf                { Load whether to lock/unlock file area.}
  517.   Mov BX,fHandle                { Handle of file to lock.               }
  518.   Mov CX,StartOfs.WORD[0]       { Load StartOfs Into  CX:DX.            }
  519.   Mov DX,StartOfs.WORD[2]
  520.   Mov SI,Len.WORD[0]            { Load Len Into SI:DI.                  }
  521.   Mov DI,Len.WORD[2]
  522.   Int $21                       { Call dos to lock area.                }
  523.   Jnc @Exit                     { If no error exit.                     }
  524.   Mov fError,AX                 { If there was an  error save it.       }
  525. @Exit:
  526. END;{fLock}
  527.  
  528. BEGIN
  529. END.{FileIO}
  530.